package com.rex.saas.bean;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @ClassName BaseResponse
 * @Description:
 * @Author: zhusiyu
 * @CreateDate: 2024/12/11 19:26	//创建时间
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
public class BaseResponse {

    private int code ;
    private String msg;
    private Object data;

    public static BaseResponse ok(){
        return new BaseResponse(200,"success",null);
    }
    public static BaseResponse ok(Object data){
        return new BaseResponse(200,"success",data);
    }
    public static BaseResponse error(int code,String msg){
        return new BaseResponse(code,msg,null);
    }
    public static BaseResponse error(ResultCode resultCode){
        return new BaseResponse(resultCode.getStatus(),resultCode.getMessage(),null);
    }
    public static BaseResponse error(String msg,ResultCode resultCode){
        return new BaseResponse(resultCode.getStatus(),msg + resultCode.getMessage(),null);
    }
    public static BaseResponse abnormal(String msg) {
        return new BaseResponse(500,msg,null);
    }

    public boolean isSuccess() {
        return code == 200;
    }
}
